﻿using OSSUtility;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Ozone.Views.DataCenter
{
    /// <summary>
    /// UCDataCenterMain.xaml 的交互逻辑
    /// </summary>
    public partial class UCDataCenterMain : UserControl
    {
        private List<Grid> lstTabGridContent = new List<Grid>();
        private List<Border> lstTabButtonGrid = new List<Border>();
        public UCDataCenterMain()
        {
            InitializeComponent();
            Init();
        }

        private void Init()
        {

            //TAB页对应的内容
            lstTabGridContent.Add(gridCenter1);
            lstTabGridContent.Add(gridCenter2);
            lstTabGridContent.Add(gridCenter3);

            //TAB页按钮
            lstTabButtonGrid.Add(gridTab1);
            lstTabButtonGrid.Add(gridTab2);
            lstTabButtonGrid.Add(gridTab3);
        }


        /// <summary>
        /// 切换Tab页
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MenuText_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            string tag = ((Border)sender).Tag.ToString();
            int nIndex = Utility.str2int(tag);
            ChangeTabItem(nIndex);
        }
        private void ChangeTabItem(int nIndex)
        {
            //找到资源 背景色
            var myResourceDictionaryShared = new ResourceDictionary
            {
                Source = new Uri("Resources/Styles/Shared.xaml", UriKind.RelativeOrAbsolute) // 指定样式文件的路径
                                                                                             //    Source = new Uri("Resources/Styles/Expander.xaml", UriKind.RelativeOrAbsolute) // 指定样式文件的路径
            };
            //按钮点击背景色
            SolidColorBrush Brush_PurpleBackColor = myResourceDictionaryShared["Brush_WindowBackColor"] as SolidColorBrush; // 通过key找到指定的样式
            //按钮背景色
            SolidColorBrush Brush_MainBackColor = myResourceDictionaryShared["Brush_MainBackColor"] as SolidColorBrush; // 通过key找到指定的样式
            for (int i = 0; i < lstTabGridContent.Count; i++)
            {
                if (i == nIndex)
                {
                    lstTabButtonGrid[i].Background = Brush_PurpleBackColor;
                    lstTabGridContent[i].Visibility = Visibility.Visible;
                }
                else
                {
                    lstTabButtonGrid[i].Background = Brush_MainBackColor;
                    lstTabGridContent[i].Visibility = Visibility.Collapsed;
                }
            }
        }
    }
}
